package keeto.com.vn.bms.network.task;

import java.io.IOException;

import keeto.com.vn.bms.config.IBMSConfig;
import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.request.GetDetailSergeryRequest;
import keeto.com.vn.bms.network.response.GetDetailSergeryResponse;
import keeto.com.vn.bms.utils.BMSListener;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

public class TaskGetDetailSergery extends AbstractTask{
	String id;
	String AuthKey;
	
	public TaskGetDetailSergery(BMSListener listener, IBMSCore core, String id,
			String authKey) {
		super(listener, core);
		this.id = id;
		AuthKey = authKey;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException, IOException {
		GetDetailSergeryRequest request = new GetDetailSergeryRequest();
		request.setId(id);
		request.setAuthenKey(AuthKey);
		GetDetailSergeryResponse reponse = protocol.getDetailSergery(request);
		for (BMSListener mListener : listener){
			mListener.finishgetDetailSergery(reponse.getReturnCode(),
					reponse.getResultMsg(), reponse.getItemDetail(),
					reponse.getItemDetailTechniciansModel(),
					reponse.getItemDetailListUserRelatedModel());
		}
	}

	@Override
	public void timeoutCallback() {
		for (BMSListener mListener : listener){
			mListener.finishgetDetailSergery(protocol.STATUS_CODE_GENERIC_FAIL_CONECTTION,"",null,null,null);
		}
	}

}
